package 力扣_滑动窗口.第一类模板.放弃;

/**
 * @author zx
 * @create 2022-05-10 21:42
 * 放弃
 */
public class 尽可能使字符串相等_1208 {
    public int equalSubstring(String s, String t, int maxCost) {
        int[] arr = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            arr[i] = Math.abs(s.charAt(i) - t.charAt(i));
        }
        int maxLength = 0;
        int left = 0;
        int sum = 0;
        for(int right = 0;right < s.length();right++){
            sum += arr[right];
            while (sum > maxCost) {
                sum -= arr[left];
                left++;
            }
            maxLength = Math.max(maxLength, right - left + 1);
        }
        return maxLength;
    }
}
